/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testing.jee.util;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import org.apache.log4j.Logger;

/**
 *
 * @author kreisera
 */
public class HolidayUtils {

    private final static Logger logger = Logger.getLogger(HolidayUtils.class);
    private final static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    private final static Properties holidayProps = new Properties();

    static {
        try {
            holidayProps.load(HolidayUtils.class.getResourceAsStream("holidays.properties"));
        } catch (IOException ex) {
            logger.error("Unable to load holidays", ex);
        }
    }
    
    public static String getHolidayName(Date date) {
        String dateString = dateFormat.format(date);
        return holidayProps.getProperty(dateString);
    }
    
    public static boolean isHoliday(Date date) {
        String dateString = dateFormat.format(date);
        if (holidayProps.containsKey(dateString))
            return true;
        return false;
    }
}
